<template>
  <div class="home">
    <Button @click="toggleLogin">测试1</Button>
    <Button @click="toggleLogin1">测试2</Button>
    <span>{{ String(isLogin) }}</span>
  </div>
</template>

<script>
import { Button } from "ant-design-vue";
import { mapGetters, mapMutations, mapActions } from "vuex";

export default {
  name: "view-home",
  components: {
    Button,
  },
  created() {
    // this.testSearchApi();
    // this.testGetApi();
  },
  data() {
    return {
      title: "Hello",
    };
  },
  computed: {
    // ...mapState("user", ["isLogin"]),
    ...mapGetters("user", ["getLogin"]),
    ...mapGetters(["isLogin"]),
  },
  methods: {
    ...mapMutations("user", ["setData"]),
    ...mapActions("user", ["login"]),
    toggleLogin() {
      this.setData({ isLogin: !this.isLogin });
    },
    toggleLogin1() {
      this.login(!this.isLogin);
    },
    testSearchApi() {
      this.$http
        .post("/web/commodityinfo/seach.do", {
          pageNum: 1,
          pageSize: 15,
        })
        .then((res) => {
          console.log(res);
        });
    },
    testGetApi() {
      this.$http
        .get("/web/area/getList.do", {
          params: {
            pageNum: 1,
            pageSize: 15,
          },
        })
        .then((res) => {
          console.log(res);
        });
    },
  },
};
</script>

<style scoped lang="less">
.home {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}
</style>
